(*
  Copyright (c) 2009 Barry Schwartz

  Permission is hereby granted, free of charge, to any person
  obtaining a copy of this software and associated documentation
  files (the "Software"), to deal in the Software without
  restriction, including without limitation the rights to use,
  copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the
  Software is furnished to do so, subject to the following
  conditions:

  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  OTHER DEALINGS IN THE SOFTWARE.
*)

open XNum
open UTypes
open Substitute
open GlyphMetric
open FontMetric
(* open Sexplib *)
  
type hyphen_params = {
  hyphenate : Hyphenation.hyphenator;
  hyphen_penalty : num;
  ex_hyphen_penalty : num;
  left_hyphen_min : int;
  right_hyphen_min : int;
  script_lang : uc_string
} (* with sexp_of *)

type ('box, 'cmd) glyph_composer = (font_metric, 'box, 'cmd) Substitute.glyph_composer (* with sexp_of *)
type ('box, 'cmd) simple_glyph_item = (font_metric, 'box, 'cmd) glyph_item (* with sexp_of *)
type ('box, 'cmd) extended_glyph_item = (font_metric * (('box, 'cmd) glyph_composer), 'box, 'cmd) glyph_item (* with sexp_of *)

val strip_composer : ('box, 'cmd) extended_glyph_item -> ('box, 'cmd) simple_glyph_item
  
val convert_to_glyph :
  font_metric ->
  ('box, 'cmd) glyph_composer ->
  ('box, 'cmd) char_item ->
  ('box, 'cmd) extended_glyph_item
  
val convert_to_glyphs :
  font_metric ->
  ('box, 'cmd) glyph_composer ->
  ('box, 'cmd) char_item list ->
  ('box, 'cmd) extended_glyph_item array
    
val convert_to_glyphs_and_add_breaks :
  hyphen_params ->
  font_metric ->
  ('box, 'cmd) glyph_composer ->
  ('box, 'cmd) char_item list ->
  ('box, 'cmd) extended_glyph_item list
    
val add_lig_kern :
  keep_breaks:bool ->
  ('box, 'cmd) extended_glyph_item list ->
  ('box, 'cmd) simple_glyph_item list
    
val add_lig_kern_iterative_list :
  keep_breaks:bool ->
  ('box, 'cmd) simple_glyph_item list ->
  ('box, 'cmd) extended_glyph_item list ->
  ('box, 'cmd) simple_glyph_item list * int * ('box, 'cmd) extended_glyph_item list
    
val add_lig_kern_iterative_array :
  keep_breaks:bool ->
  ('box, 'cmd) simple_glyph_item list ->
  int ->
  int ->
  ('box, 'cmd) extended_glyph_item array ->
  ('box, 'cmd) simple_glyph_item list * int
    
val add_lig_kern_finish :
  ('box, 'cmd) simple_glyph_item list ->
  int ->
  int ->
  ('box, 'cmd) extended_glyph_item array ->
  ('box, 'cmd) simple_glyph_item list
    
val dump_item :
  [<
  | `Char of uc_char
  | `Glyph of glyph_desc * font_metric
  | `Kern of num * num
  | `Box of 'box
  | `Command of 'cmd
  | `Break of 'break
  ] -> unit
  
val dump_item_list :
  [<
  | `Char of uc_char
  | `Glyph of glyph_desc * font_metric
  | `Kern of num * num
  | `Box of 'box
  | `Command of 'cmd
  | `Break of 'break
  ] list -> unit
  
val dump_item_array :
  [<
  | `Char of uc_char
  | `Glyph of glyph_desc * font_metric
  | `Kern of num * num
  | `Box of 'box
  | `Command of 'cmd
  | `Break of 'break
  ] array -> unit

val empty_hyphen_params : hyphen_params
